using System;
using System.Collections.Generic;
using System.Text;

namespace Coriander.Google.Charting.Data.Generic
{
    /// <summary>
    /// Represents a typed dataset
    /// </summary>
    public class Dataset<T> : IChartDataset<T>
    {
        Queue<T> values;

        /// <summary>
        /// 
        /// </summary>
        protected Queue<T> Values
        {
            get { return values ?? (values = new Queue<T>()); }
        }

        /// <summary>
        /// Adds a value
        /// </summary>
        /// <param name="item"></param>
        public void Add(T item) 
        {
            Values.Enqueue(item); 
        }

        /// <summary>
        /// Add a range of values
        /// </summary>
        /// <param name="items"></param>
        public void AddRange(IEnumerable<T> items)
        { 
            if (null == items)
                throw new ArgumentNullException("items");

            foreach (T item in items)
            {
                Add(item); 
            }
        }

        /// <summary>
        /// Get the underlying array of <typeparamref name="T">T</typeparamref>.
        /// </summary>
        /// <returns></returns>
        public T[] GetValues() 
        {
            return values.ToArray();  
        }
    }
}
